<!DOCTYPE html>
<html lang="zh-cn" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>孤立作用域单向绑定</title>
    <script src="https://cdn.bootcss.com/angular.js/1.6.6/angular.js"></script>
</head>
<body>
<div ng-controller="myCtrl">
    用户名:<input type="text" ng-model="name">
    <hello my-name="{{name}}"></hello>
</div>
<script>
    var app = angular.module("app", []);
    app.controller("myCtrl", function ($scope) {
        $scope.name = "slash";
    });
    app.directive("hello", function () {
        return {
            restrict: "AEC",
            scope: {
                name: "@myName"
            },
            template: "<h1>hello,{{name}}</h1><input ng-model='name'>"
        }
    });
</script>
</body>
</html>